import Cookies from "js-cookie";

const TokenKey = "Token";

export function getToken() {
  return Cookies.get(TokenKey);
}

export function setToken(token) {
  return Cookies.set(TokenKey, token);
}

export function removeToken() {
  return Cookies.remove(TokenKey);
}

export function removeCookies() {
  let cookieObj = Cookies.get();

  // 清空所有cookie
  for (let key in cookieObj) {
    Cookies.remove(key);
  }

  if (JSON.stringify(Cookies.get()) == "{}") {
    // 清空cookie成功
    return true;
  } else {
    // 清空cookie失败
    return false;
  }
}
